<template>
    <div>
      <input v-model="inputValue" />
      <button @click="addItem">提交</button>
      <ul>
        <li 
          v-for="(item,index) of list" 
          :key="index"
          @click="delItem(index)"
          >
          {{item}}
        </li>
      </ul>

      <ul>
        <todo-item 
        v-for="(item,index) of list" 
        :key="index"
        :content="item"
        :index="index"
        @delete="delItem">
        </todo-item>
      </ul>
    </div>
</template>

<script>

import TodoItem from './components/TodoItem'

export default {
  data () {
    return {
      inputValue: '',
      list: []
    }
  },
  methods : {
      addItem () {
      this.list.push(this.inputValue);
      this.inputValue='';
    },
      delItem (index) {
        this.list.splice(index , 1);
      }
  },
  components: {
    'todo-item' : TodoItem
  }
}
</script>

<style>

</style>
